package com.senthink.gl.business.domain.repository;

import com.senthink.gl.business.domain.entity.People;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

/**
 * 民众Repository
 *
 * @author zooqi@senthink.com
 * @date 2017/11/28
 */
public interface PeopleRepository extends JpaRepository<People, Long>, JpaSpecificationExecutor<People> {

    /**
     * 查找
     *
     * @param idcard
     * @return
     */
    Optional<People> findTopByIdcard(String idcard);

    /**
     * 查找
     * @param pid
     * @return
     */
    Optional<People> findTopByPid(String pid);


    /**
     * 删除
     *
     * @param pid
     * @return
     */
    @Transactional
    long deleteByPid(String pid);

    /**
     * 计数
     *
     * @param idcard
     * @return
     */
    long countByIdcard(String idcard);



}